package com.bwie.home.backstage.controller;

import java.util.Arrays;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bwie.home.backstage.entity.CommunityEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.bwie.home.backstage.entity.BuylogEntity;
import com.bwie.home.backstage.service.BuylogService;
import com.bwie.home.common.utils.R;



/**
 * 
 *
 * @author sy
 * @email sunlightcs@gmail.com
 * @date 2021-09-10 09:46:41
 */
@RestController
@RequestMapping("backstage/buylog")
public class BuylogController {
    @Autowired
    private BuylogService buylogService;

    /**
     * 获取所有房源成交列表
     */
    @PostMapping("/list")
    public R list(@RequestParam(value = "page",defaultValue = "1")int page,
            @RequestParam(value = "limit",defaultValue = "2")int limit,@RequestBody CommunityEntity community){
        IPage<BuylogEntity> p=buylogService.getList(page,limit,community);

        return R.ok().put("page", p);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{buylogId}")
    public R info(@PathVariable("buylogId") Integer buylogId){
		BuylogEntity buylog = buylogService.getById(buylogId);

        return R.ok().put("buylog", buylog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BuylogEntity buylog){
		buylogService.save(buylog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BuylogEntity buylog){
		buylogService.updateById(buylog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] buylogIds){
		buylogService.removeByIds(Arrays.asList(buylogIds));

        return R.ok();
    }


}
